package fi.helsinki.cs.ohtu10k.view;

import javax.swing.*;
import java.awt.*;
import java.util.*;

/**
 * Class implementing the weekly events panel. 
 * @author Simo Hellsten
 *
 */
@SuppressWarnings("serial")
public class WeekEventsPanel extends JPanel{
	
	private ArrayList<JLabel> events;
	private ArrayList<DummyEvent> eventList;
	                     
    public WeekEventsPanel(int dayWidth, int hourHeight, int labelWidth, int labelHeight, int hoursPerDay, int firstHour, int offsetX, int offsetY) {
    	events = new ArrayList<JLabel>();
		this.setLayout(null);
		this.setOpaque(false);
		
    	eventList = new ArrayList<DummyEvent>();
    	eventList.add(new DummyEvent(1,10,2,false,"OhTu","Luento"));
    	eventList.add(new DummyEvent(1,12,2,false,"ElVis","Elokuva"));			
    	eventList.add(new DummyEvent(2,12,2,false,"OhTu","Luento"));
    	eventList.add(new DummyEvent(2,16,4,true,"ExKu","Tentti"));
    	eventList.add(new DummyEvent(3,10,2,false,"OhTu","Luento"));
    	eventList.add(new DummyEvent(3,12,2,false,"ElVis","Visualisointi"));			
    	eventList.add(new DummyEvent(4,12,2,false,"OhTu","Laskarit"));			
    	eventList.add(new DummyEvent(4,14,2,false,"ElVis","Laskarit"));			

	
		for (DummyEvent d: eventList) {
	    	JLabel l = new JLabel("<html>"+d.startDateTime+"-"+(d.startDateTime+d.duration)+"<br>"+d.course+"<br>"+d.name+"<html>");
			l.setBounds(offsetX+labelWidth+dayWidth*d.startDateWeekday+1,offsetY+labelHeight+hourHeight*(d.startDateTime-firstHour)+1,dayWidth-1,hourHeight*d.duration-1);
			l.setOpaque(true);
			if (d.important)
				l.setBackground(Color.red);
			else 
				l.setBackground(Color.yellow);
	    	events.add(l);			
		}
		for (JLabel e: events) {
			this.add(e);	    			
		}
    }
	public void paintComponent(Graphics g) {
		super.paintComponent(g);	
	}
	
	public class DummyEvent {
		public int startDateWeekday;
		public int startDateTime;
		public int duration;
		public boolean important;
		public String course;
		public String name;

		public DummyEvent(int w, int t, int d, boolean i, String c, String n) {
			startDateWeekday = w;
			startDateTime = t;
			duration = d;
			important = i;
			course = c;
			name =  n;			
		}
	}
}

